<?php
/**
 * CatalogController
 * 
 * @author
 * @version 
 */
require_once 'Zend/Controller/Action.php';
class News_CatalogController extends Zend_Controller_Action
{
    /**
     * @var News_Model_Catalog
     */
    protected $_catalogModel;
    
    public function init()
    {
        $this->_catalogModel = new News_Model_Catalog();
    }
    
    /**
     * The default action - show the home page
     */
    public function indexAction ()
    {    
        $category = $this->_catalogModel->getCategoryById($this->_getParam('cid',''));
        
        if (null === $category)
        {
            throw new GM_Exception_404('未知的分区' . $this->_getParam('cid'));
        }
        
        $this->getBreadcrumb($category);
        
        $this->view->assign(array(
            'category'    => $category));
    }
    
    public function getBreadcrumb($category)
    {
        $this->view->bread = $this->_catalogModel->getParentCategories($category);
    }
}

